#ifndef __AVERAGIZER__H
#define __AVERAGIZER__H
template <class T = F64, bool SUM = true>
class Averagizer {
public:
	Averagizer() {  m_nSum = m_nCount = 0; }
	void Add(T x) {
		++m_nCount;
		if (SUM)
			m_nSum += x;
		else
			m_nSum += (x - m_nSum) / m_nCount;
	}
	T Get() {
		if (SUM)
			return m_nSum / m_nCount;
		else
			return m_nSum;
	}
	U32 Count() { return m_nCount; }
private:
	T m_nSum;
	U32 m_nCount;
};
#endif
